package com.youmi.android.sample;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends Activity {
	public final static String EXTRA_MESSAGE = "com.youmi.android.sample.MESSAGE";
	/**
	 * 
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.action_search:
			System.out.println("click sarch");
			return true;
		case R.id.action_search2:
			System.out.println("click sarch2");
			return false;
		default:
			return super.onOptionsItemSelected(item);
		}
	}

	/**
	 * onClick event
	 * @param v
	 */
	public void sendMessage(View v){
		EditText editText=(EditText)findViewById(R.id.txtFirst);
		String msg=editText.getText().toString();
		
		if(msg==null || "".equals(msg)){
			return;
		}
		
		Intent intent=new Intent(this,DisplayMessageActivity.class);
		intent.putExtra(EXTRA_MESSAGE, msg);
		startActivity(intent);
	}
}
